package com.dwork.base.validate.tag;

import java.util.List;

import freemarker.template.TemplateMethodModel;
import freemarker.template.TemplateModelException;

public class TagValidateJS implements TemplateMethodModel {

	@Override
	public Object exec(List arguments) throws TemplateModelException {
		if(arguments==null) {
			throw new TemplateModelException("参数列表为空！");
		}
		if(arguments.size()!=4) {
			throw new TemplateModelException("参数个数不对！");
		}
		try {
			EntityValidateJSFactory entityValidateJSFactory = new EntityValidateJSFactory(arguments.get(0).toString(), arguments.get(1).toString(), arguments.get(2).toString(),arguments.get(3).toString());
			return entityValidateJSFactory.productJS();
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return "//内部错误:(9534)，生成出错!";
	}

}
